#include "StdAfx.h"
#include"TButtonUI.h"

void TButtonUI::PaintBkColor(HDC hDC)
{

	vector4 pos = GetPos();
	SIZE bordsize = GetBorderRound();

	if ((m_uButtonState & UISTATE_DISABLED) != 0) {
		if (m_dwDisabledBkColor != 0) {
			CRenderEngine::DrawColor(hDC, m_rcPaint, GetAdjustColor(m_dwDisabledBkColor));
			return;
		}
	}
	else if ((m_uButtonState & UISTATE_PUSHED) != 0) {
		if (m_dwPushedBkColor != 0) {
			GdiPlusRender::DrawRoundRectangle(hDC, pos.x, pos.y, pos.w - 1, pos.h - 1, bordsize.cx / 2, 1, m_dwPushedBkColor, true, 0);
			//CRenderEngine::DrawColor(hDC, m_rcPaint, GetAdjustColor(m_dwPushedBkColor));
			return;
		}
	}
	else if ((m_uButtonState & UISTATE_HOT) != 0) {
		if (m_dwHotBkColor != 0) {
		
			GdiPlusRender::DrawRoundRectangle(hDC, pos.x, pos.y, pos.w-1, pos.h-1, bordsize.cx/2, 1, m_dwHotBkColor, true, 0);
			//CRenderEngine::DrawColor(hDC, m_rcPaint, GetAdjustColor(m_dwHotBkColor));
			return;
		}
	}

	return CControlUI::PaintBkColor(hDC);
}

LPCTSTR TButtonUI::GetClass() const
{
	return _T("TButtonUI");
}

LPVOID TButtonUI::GetInterface(LPCTSTR pstrName)
{
	if (_tcsicmp(pstrName, _T("TButton")) == 0)
	{
		return static_cast<TButtonUI*>(this);
	}
	return __super::GetInterface(pstrName);
}
